package com.zhss.eshop.auth.service.impl;

import com.zhss.eshop.auth.dao.PriorityDAO;
import com.zhss.eshop.auth.domain.Priority;
import com.zhss.eshop.auth.domain.PriorityDO;
import com.zhss.eshop.auth.domain.PriorityDTO;
import com.zhss.eshop.auth.service.PriorityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author hanmeng
 * @Date 13:56 2021/4/4
 * @Version 1.0
 **/
@Service
public class PriorityServiceImpl implements PriorityService {
    private static final Logger logger = LoggerFactory.getLogger(PriorityServiceImpl.class);

    @Autowired
    private PriorityDAO priorityDAO;

    /**
     * 查询根权限
     * @return 根权限集合
     */
    @Override
    public List<PriorityDTO> listRootPriorities() throws Exception {
        List<PriorityDTO> priorityDTOs = null;
      try {
          List<PriorityDO> priorityDOs = priorityDAO.listRootPriorities();
          if (CollectionUtils.isEmpty(priorityDOs)){
              return null;
          }
          priorityDTOs = new ArrayList<PriorityDTO>(priorityDOs.size());
          for (PriorityDO priorityDO : priorityDOs){
              priorityDTOs.add(priorityDO.clone(PriorityDTO.class));
          }
          return priorityDTOs;
      }catch (Exception e){
          logger.error("error",e);
      }
      return priorityDTOs;
    }

    @Override
    public List<PriorityDTO> listChildPriorities(Long parentId) throws Exception {
        return null;
    }

    @Override
    public PriorityDTO getPriorityById(Long id) throws Exception {
        return null;
    }

    @Override
    public List<Priority> listAuthorizedByAccountId(Long accountId) throws Exception {
        return null;
    }

    @Override
    public Boolean existAuthorizedByCode(Long accountId, String code) throws Exception {
        return null;
    }

    @Override
    public Boolean existAuthorizedByUrl(Long accountId, String url) throws Exception {
        return null;
    }

    @Override
    public void savePriority(PriorityDTO priorityDTO) throws Exception {

    }

    @Override
    public void updatePriority(PriorityDTO priorityDTO) throws Exception {

    }

    @Override
    public Boolean removePriority(Long id) throws Exception {
        return null;
    }
}
